import os
from cryptography.fernet import Fernet
from typing import Dict, Any

# 网络配置
HOST = "localhost"
PORT = 5000

# 日志配置
LOG_LEVEL = "INFO"
LOG_FORMAT = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
LOG_DIR = "logs"

# 确保日志目录存在
os.makedirs(LOG_DIR, exist_ok=True)

# 数据质量检查配置
QUALITY_THRESHOLDS: Dict[str, Any] = {
    "completeness": 0.95,  # 完整性阈值
    "accuracy": 0.90,      # 准确性阈值
    "consistency": 0.85,   # 一致性阈值
    "timeliness": 0.80     # 时效性阈值
}

# 基础配置
DATA_DIR = 'data'
REPORT_DIR = 'reports'

# 确保必要的目录存在
os.makedirs(DATA_DIR, exist_ok=True)
os.makedirs(REPORT_DIR, exist_ok=True)

# 生成或加载加密密钥
def get_or_create_key():
    key_file = os.path.join(DATA_DIR, '.fernet_key')
    if os.path.exists(key_file):
        with open(key_file, 'rb') as f:
            return f.read()
    else:
        key = Fernet.generate_key()
        with open(key_file, 'wb') as f:
            f.write(key)
        return key

# 获取加密密钥
FERNET_KEY = get_or_create_key() 